package com.turing.controller;


import com.turing.domain.Company;
import com.turing.service.ICompanyService;
import com.turing.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("company")
public class CompanyController {

    @Autowired
    private ICompanyService companyService;

    /**
     * 查所有
     */
    @GetMapping("/list")
    public AjaxResult selectAll() {
        List<Company> list=companyService.selectAll();
        return AjaxResult.success(list);
    }

    /**
     * 根据id 查一条
     */
    @GetMapping("/{id}")
    public Company selectById(@PathVariable() Long id) {
        return companyService.selectById(id);
    }

    /**
     * 添加
     */
    @PostMapping()
    public int insertOne(@RequestBody Company company) {
        return companyService.insertOne(company);
    }

    /**
     * 修改
     */
    @PutMapping()
    public int updateById(@RequestBody Company company) {
        return companyService.updateById(company);
    }

    /**
     * 删除
     */
    @DeleteMapping("/{ids}")
    public int deleteByIds(@PathVariable() Long[] ids) {
        return companyService.deleteByIds(ids);
    }
}
